﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meraz.Core.Model;

namespace Meraz.Core.Repositories
{
    public class TopicRepository : EFRepositoryBase<Topic, int>, ITopicRepository
    {
        public TopicRepository() : base() { }
        public TopicRepository(Data.IMerazContext context) : base(context) { }

        public override Topic GetById(int id)
        {
            return context.Topics
                .Where(where1 => where1.ID == id)
                .FirstOrDefault();
        }

        public Topic Get(string name)
        {
            return context.Topics
                .Where(where1 => where1.Name == name)
                .FirstOrDefault();
        }

        public override void Add(Topic entity)
        {
            context.Topics.AddObject(entity);
        }

        public override void Delete(Topic entity)
        {
            context.Topics.DeleteObject(entity);
        }

        public override List<Topic> All()
        {
            return context.Topics.ToList();
        }
    }
}
